Estoy usando getStaticProps() en una aplicación Next.js pero cuando ejecuto la aplicación da ERROR: -
warn - Attempted to load @next/swc-win32-x64-gnu, but it was not installed warn - Attempted to load @next/swc-win32-x64-msvc, but an error occurred: The specified module could not be found. \\?\D:\tasks\next-js\node_modules\@next\swc-win32-x64-msvc\next-swc.win32-x64-msvc.node error - Failed to load SWC binary for win32/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! next-js@0.1.0 dev: `next dev` npm ERR! Exit status 1 npm ERR! Probé todos los métodos, como desinstalar node_module, bloquear el paquete y volver a instalarlo. Intenté agregar el archivo .babelrc, también agregué swcMinify: false en next.config pero nada funciona.
Cuando uso useEffect en lugar de getStaticProps, funciona bien. Aquí está la función getStaticProps: -
export const getStaticProps = async () =>{ const res = await fetch('https://jsonplaceholder.typicode.com/posts'); const data = await res.json(); return{ props: { data, } }; };Este problema aparece cuando se ejecuta next@12.1.6 y sucede incluso si su archivo .babelrc y next.config.js están configurados para no cargar swc.
Si cambia a next@12.1.0 , el error de carga binaria swc debería desaparecer.